#define _CRT_SECURE_NO_WARNINGS 1
#include<queue>
using namespace std;
class RecentCounter {
    queue<int> q;
public:
    RecentCounter() {

    }

    int ping(int t)
    {
        q.push(t);
        while (q.front() < t - 3000)
        {
            q.pop();
        }
        return q.size();
    }
};